package com.example.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    EditText etName;
    EditText etPassword;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button btnRegister= (Button) findViewById(R.id.btn_register);
         etName= (EditText) findViewById(R.id.et_name);
         etPassword= (EditText) findViewById(R.id.et_password);
        btnRegister.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                //判断输入框是否为空
                if (TextUtils.isEmpty(etName.getText())|TextUtils.isEmpty(etPassword.getText())){
                    Toast.makeText(MainActivity.this,"用户名和密码不能为空",Toast.LENGTH_LONG).show();
                }else {
                    //点击，跳转到下一页，将用户名和密码传递到下一页
                    //显式意图，指出当前Activity和要条旋转的Activity的名字
                    Intent intent=new Intent(getApplicationContext(),DetailInfoActivity.class);
                    //准备数据
                    String name=etName.getText().toString();
                    String psw=etPassword.getText().toString();


                    //将数据放intent

                    intent.putExtra("userpsw",psw);
                    intent.putExtra("username",name);

                    //跳转
                    startActivity(intent);
                }



            }
        });



    }
}
